Skip to content

add drag uploader#23011

Merged
cedric-anne merged 15 commits intoglpi-project:mainfrom
f2cmb:kb/modal/upload
Mar 12, 2026
Merged

add drag uploader#23011
cedric-anne merged 15 commits intoglpi-project:mainfrom
f2cmb:kb/modal/upload

Conversation

@f2cmb
Copy link
Contributor

@f2cmb f2cmb commented Feb 4, 2026

  • I have read the CONTRIBUTING document.
  • I have performed a self-review of my code.
  • I have added tests that prove my fix is effective or that my feature works.
  • This change requires a documentation update.

Description

Add an uploader to documents modal for new KB/

Screenshots (if appropriate):

@f2cmb f2cmb linked an issue Feb 4, 2026 that may be closed by this pull request
@cconard96
Copy link
Contributor

cconard96 commented Feb 4, 2026

Unless this design is only going to be used for KB, IMO it should be made its own component and not put in the KB styles/code.

@f2cmb f2cmb marked this pull request as ready for review February 5, 2026 13:30
Copy link
Contributor

@AdrienClairembault AdrienClairembault left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the upload to tmp part should start immediately when the file is added, that's how it works on gmail for example.

Also, if I upload a file that is not allowed (a .json for example), I don't have any error and my file is just silently ignored.

@f2cmb
Copy link
Contributor Author

f2cmb commented Feb 9, 2026

Removed dead code for file verification. Add immediate uploads.

Copy link
Contributor

@AdrienClairembault AdrienClairembault left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good functionally but I'd like to wait for @cedric-anne opinion on the technical side as this changes a lot compared to our traditional "legacy" jquery file uploader system.

If we validate it, it should indeed be move into a re-usable module so it can be used for others features as a replacement of the old jquery file uploader.

@cedric-anne
Copy link
Member

Looks good functionally but I'd like to wait for @cedric-anne opinion on the technical side as this changes a lot compared to our traditional "legacy" jquery file uploader system.

If we validate it, it should indeed be move into a re-usable module so it can be used for others features as a replacement of the old jquery file uploader.

The current uploader component we use is not maintained anymore, and this is why we had to embed its sources in our repository. Therefore, I think it is a good idea to build our own component, and plan to use it in the whole GLPI code base in a future version.
It is preferable to keep it simple for the moment, but in a later PR, it could be a good idea to handle uploads by chunks, in order to be able to upload large documents without having to modify the PHP configuration. The current componant handles it.

@f2cmb
Copy link
Contributor Author

f2cmb commented Feb 20, 2026

Extracted the file uploader dropzone markup from article.html.twig into a standalone partial. The JS (FileUploader.js) and SCSS (_file-uploader.scss) were already generic ; this completes the extraction by making the Twig layer reusable too.

Tested reusability by replacing fields.fileField() in form_document_item.html.twig with the new partial + a FileUploader init : the dropzone renders correctly, drag & drop and immediate upload work out of the box.

Full integration would require an adapter controller.

To try the partial anywhere in GLPI :

  {{ include('components/form/file_uploader.html.twig', {
      'input_id': 'my-upload-input',
  }, with_context = false) }}

  <script type="module">
      import { FileUploader } from '/js/modules/FileUploader.js';
      new FileUploader(document.getElementById('my-container'));
  </script>

@cedric-anne cedric-anne added this to the 12.0.0 milestone Mar 2, 2026
@f2cmb f2cmb requested a review from cedric-anne March 4, 2026 09:47
@f2cmb f2cmb force-pushed the kb/modal/upload branch from 365f823 to 42d2107 Compare March 5, 2026 08:53
@cedric-anne cedric-anne merged commit aee8abb into glpi-project:main Mar 12, 2026
9 checks passed
@f2cmb f2cmb deleted the kb/modal/upload branch March 12, 2026 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Functional upload modal

4 participants